import { GameManager } from "./GameManager";


const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {


    start () {
        let url ='127.0.0.1:4747'
        url = '192.168.0.111:4747'
        let manager =  GameManager.Instance(GameManager);
        manager.queueSocket=  io.connect(url+'/queue', { 'force new connection': true });
        cc.log(manager.queueSocket)
        manager.queueSocket.on('setPlayerIndex',(index)=>{
            manager.playerIndex = index
            cc.log('选手号:'+manager.playerIndex)
        })

        manager.queueSocket.on('match success',  (roomId)=> {
            cc.log('match success' + roomId);
            cc.log(roomId)
            manager.roomSocket = io.connect(url+'/rooms' + roomId, { 'force new connection': true });
            //manager.queueSocket.disconnect();
            cc.director.loadScene('main');
        });
    }
}
